﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net;
using System.Text;

namespace Webservice.Tests
{
    [TestClass]
    public class APIControllerTest
    {
        [TestMethod]
        public void PutCSVFile_Expect_Success_Response_String()
        {
            Webservice.Controllers.ReportController api = new Webservice.Controllers.ReportController();
            var result = api.Put("TEST", new StreamReader(@"Assets\GoodCSV.csv").ReadToEnd());

            Assert.IsInstanceOfType(result, typeof(string));
            /*
            var jsonObject = JObject.Parse(result);

            Assert.IsNotNull(jsonObject["status"]);

            string status = jsonObject["status"].ToString();
            */
            Assert.AreEqual("success", result);
        }

        [TestMethod]
        public void PutCSVFile_Expect_Failed_Response_String()
        {
            Webservice.Controllers.ReportController api = new Webservice.Controllers.ReportController();
            string result = api.Put("TEST", new StreamReader(@"Assets\BadCSV.csv").ReadToEnd());

            Assert.IsInstanceOfType(result, typeof(string));
            /*
            var jsonObject = JObject.Parse(result);

            Assert.IsNotNull(jsonObject["status"]);

            string status = jsonObject["status"].ToString();
            */
            Assert.AreEqual("failed", result);
        }
    }
}